<?php
namespace App\Http\Controllers\Customer;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Query\GoodsDetailQuery;
use Illuminate\Support\Facades\DB;

class JapanOrderRemainingController extends Controller
{


    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Http\Response
     */
    public function order_remaining(Request $request)
    {
        $getParam = $request->all();
        $map = [];
        $map['uo.state'] = 0;
        $list = DB::table('user_order as uo')
            ->select(DB::raw('uo.create_time,uo.send_goods_time,sm.storehouse_name,gm.goods_id,uod.size,gm.goods_code,gm.goods_name,uod.goods_num,um.user_name,uo.deliver_state'))
            ->leftJoin('user_order_detailed as uod', 'uo.order_id', '=', 'uod.order_id')
            ->leftJoin('goods_master as gm', 'uod.goods_id', '=', 'gm.goods_id')
            ->leftJoin('user_master as um', 'um.user_id', '=', 'uo.user_id')
            ->leftJoin('storehouse_master as sm', 'uod.warehouse_id', '=', 'sm.storehouse_id')
            ->where($map)
            ->get();
        foreach ($list as $key => $value) {
            $map = [];
            $map['goods_id'] = $value->goods_id;
            $map['model_size'] = $value->size;
            $temp=DB::table('storehouse_detailed_size')
                ->first();
            if(empty($value->send_goods_time)){
                if(empty($temp) || $temp->num==0){
                    $value->send_goods_time='入荷予定';
                }else{
                    $value->send_goods_time='出荷待機中';
                }
            }
        }
        return view('customer.order_remaining', array(
            'list' => $list,
            'param' => $getParam,
        )); // 返回视图
    }

}

